package com.lzs.baseruku.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzs.baseruku.mapper.LocatorMapper;
import com.lzs.baseruku.service.LocatorService;
import com.lzs.entity.Locator;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ymx
 * @since 2020-11-24
 */
@Service
public class LocatorServiceImpl extends ServiceImpl<LocatorMapper, Locator> implements LocatorService {

    @Override
    public Page<Locator> selectLocator(Integer page, Integer limit, Locator locator) {
        Page<Locator> pageInfo=new Page<>(page,limit);
        String name=locator.getName();
        String code=locator.getCode();
        String type=locator.getType();
        Long warehouseid=locator.getWarehouseid();
        QueryWrapper queryWrapper=new QueryWrapper();

        if (StringUtils.isNotEmpty(name)){
            queryWrapper.like("name",name);
        }
        if (StringUtils.isNotEmpty(code)){
            queryWrapper.like("code",code);
        }
        if (StringUtils.isNotEmpty(type)){
            queryWrapper.like("type",type);
        }
        if (warehouseid!=null){
            queryWrapper.eq("warehouseid",warehouseid);
        }
        this.baseMapper.selectPage(pageInfo,queryWrapper);
        return pageInfo;
    }
}
